#include <vector>
#include <iostream>

using namespace std;

void calc_elements(vector<int> &, int);
void display_elems(vector<int> &, const string &, ostream & = cout);
inline bool is_size_ok(vector<int>&, int);

int main()
{
    vector<int> pent;
    const string title("Pentagonal Numberic Series");

    if (is_size_ok(pent, 5))
        display_elems(pent, title);

    if (is_size_ok(pent, 70))
        display_elems(pent, title);

    return 0;
}

void calc_elements(vector<int> &vec, int pos)
{
    for (int ix = 0; ix < pos; ix++)
        vec.push_back((ix + 1) * (3 * ix + 2) / 2);
}

void display_elems(vector<int> &vec, const string &title, ostream &os)
{
    os << "Kind: " << title << endl;
    for (int ix = 0; ix < (int)vec.size(); ix++)
        os << vec[ix] << " ";
    os << endl;
}

inline bool is_size_ok(vector<int> &vec, int pos)
{
    if ((pos <= 0) || (pos >= 64))
    {
        cerr << "Sorry. Invalid position: " << pos << endl;
        return false;
    }

    if ((int)vec.size() < pos)
        calc_elements(vec, pos);

    return true;
}